solving selection problem